package cn.kgc.commons.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * <p>线程池的配置类,创建线程池的对象</p>
 *
 * @author 卢传琪
 */
@Configuration
public class ThreadPoolConfig {
    @Bean
    public static ThreadPoolExecutor threadPoolExecutor(){
        return new ThreadPoolExecutor(5,10,5, TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(10), Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());
    }
}
